{include file="public/toper"/}

<div class="x-body">
    <form action="" method="post" class="layui-form" id="forms">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>优惠券类型
            </label>
            <div class="layui-input-inline layui-form">
                <input type="radio" name="coupons_type" lay-filter="m" value="1" checked="checked"  title="满减">
                <input type="radio" name="coupons_type" lay-filter="m" value="2" title="折扣">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>名称
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>20个字符以内
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>适用范围</label>
            <div class="layui-input-inline">
                <select name="scope" class="field-pid" type="select">
                    {$materiel}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>满足条件
            </label>
            <div class="layui-input-inline">
                <input type="number" value=""  name="conditions" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span><span id="t"></span>
            </label>
            <div class="layui-input-inline">
                <input type="number" value=""  name="discount" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>发行数
            </label>
            <div class="layui-input-inline">
                <input type="number" value="" name="number" min="1" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>5位数（0-32767）
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>发行区域
            </label>
            <div class="layui-input-inline">
                <input type="radio" name="area" value="0" checked="checked" title="平台公开">
                <input type="radio" name="area" value="1" title="抽奖">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>用户限领
            </label>
            <div class="layui-input-inline layui-form">
                <input type="radio" name="limits" id="s" value="1"  lay-filter="x"  title="限领" checked="checked">
                <input type="radio" name="limits" value="0" lay-filter="x"  title="不限领">
                <input type="number" id="limitss" min="1" name="limitss" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>限领数2位数
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>使用期限
            </label>
            <div class="layui-input-inline">
                <input type="text" id="start" value="" name="start_time" placeholder="开始日期" class="layui-input" readonly='readonly'>
            </div>
            <div class="layui-input-inline">
                <input type="text" id="settlement" value="" name="settlement_time" placeholder="结束日期"  class="layui-input" readonly='readonly'>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>发行状态
            </label>
            <div class="layui-input-inline">
                <input type="radio" name="state" value="0" title="已停售">
                <input type="radio" name="state" value="1" checked="checked" title="发行中">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button  class="layui-btn" lay-filter="formSubmit" lay-submit="">提交</button>
        </div>
    </form>
</div>

<script>
    layui.use(['form','laydate'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
        var laydate = layui.laydate;
        form.on('radio(m)', function(data){
            if(data.value==1){
                $("#t").html('满减金额')
            }else {
                $("#t").html('折扣%')
            }
        });

        form.on('radio(x)', function(data){
            if(data.value==0){
                $("#limitss").hide();
                $("#limitss").val('');
                $("#s").attr("checked",null);
                form.render('radio','x');
            }else {
                $("#limitss").show();

            }
        });

        laydate.render({
            elem: '#start'
            ,type:'datetime'
            ,min:0
        });
        laydate.render({
            elem: '#settlement'
            ,type:'datetime'
            ,min:0
        });


        $("#t").html('满减金额')


    });
</script>
{include file="public/footer"/}